<template>
	<view class="container">
		<view class="tui-dropdown-box text-center">
			<image :src="logo" mode="heightFix" class="logo"></image>
		</view>
		<view class="tui-form">
			<view class="tui-view-input">
				<tui-list-cell :hover="false" :lineLeft="false" backgroundColor="transparent">
					<view class="tui-cell-input  tui-my-input">
						<iconfont className="icon-aui-icon-mobile padding" color="#6d7a87" :size="20"></iconfont>
						<input :value="mobile" placeholder="请输入手机号" placeholder-class="tui-phcolor" type="number" maxlength="11" @input="inputMobile" />
						<view class="tui-icon-close1" v-show="password" @tap="clearInput(2)">
							<iconfont className="icon-cuowu1 padding" :size="16" color="#bfbfbf"></iconfont>
						</view>
					</view>
				</tui-list-cell>
				<tui-list-cell :hover="false" :lineLeft="false" backgroundColor="transparent">
					<view class="tui-cell-input  tui-my-input">
						<iconfont className="icon-mima padding" color="#6d7a87" :size="20"></iconfont>
						<input placeholder="请输入验证码" placeholder-class="tui-phcolor" type="text" maxlength="6" @input="inputCode" />
						<view class="tui-btn-send" :class="{ 'tui-gray': isSend }" :hover-class="isSend ? '' : 'tui-opcity'" :hover-stay-time="150" @tap="sendCode">{{ btnSendText }}</view>
					</view>
				</tui-list-cell>
				<tui-list-cell :hover="false" :lineLeft="false" backgroundColor="transparent">
					<view class="tui-cell-input  tui-my-input">
						<iconfont className="icon-mima padding" color="#6d7a87" :size="20"></iconfont>
						<input :value="password" placeholder="请输入新密码" :password="true" placeholder-class="tui-phcolor" type="text" maxlength="40" @input="inputPwd" />
						<view class="tui-icon-close1" v-show="password" @tap="clearInput(2)">
							<iconfont className="icon-cuowu1" :size="16" color="#bfbfbf"></iconfont>
						</view>
				 
					</view>
				</tui-list-cell>
			</view>
			<view class="padding-lr">
				<view class="tui-cell-text">
					<view class="tui-color-black" hover-class="tui-opcity" :hover-stay-time="150" @tap="href(1)">去登录</view>
					<view hover-class="tui-opcity" :hover-stay-time="150">
						没有账号？
						<text class="tui-color-primary" @tap="href(2)">注册</text>
					</view>
				</view>
			</view>
			<view class="padding-lr">
				<view class="tui-btn-box">
					<tui-button :disabledGray="true" type="danger" :shadow="true" shape="circle" @tap="forgetPwd">确认修改</tui-button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	computed: {
		disabled: function() {
			let bool = true;
			if (this.mobile && this.code && this.password) {
				bool = false;
			}
			return bool;
		}
	},
	data() {
		return {
			logo:'',
			mobile: '',
			password: '',
			code: '',
			usecode:true,
			isSend: false,
			btnSendText: '获取验证码' //倒计时格式：(60秒)
		};
	},
	onLoad() {
		let that = this
		that.tui.store().then((res)=>{
			that.logo = res.logo
			console.log('AAAAAAAAAA',res)
			console.log('关键词热搜',res.logo)
		}).catch((res)=>{
			console.log('shibai',res)
		});
	},
	methods: {
		forgetPwd(){
			let that = this
			that.tui.request("/user/forgetpass","POST",{
				code:that.code,
				mobile:that.mobile,
				password:that.password
			}).then((res)=>{
				console.log(res)
				if (res.code == 200) {
					console.log(res)
					this.tui.toast(res.message);
					that.tui.href('/login')
				} else {
					this.tui.toast(res.message);
				}
			}).catch((res)=>{})
		},
		href(type) {
			let that = this
			let url = '';
			if(type==1){
				url =	'login'
			}else if(type==2){
				url =	'register'
			}
			that.$Router.push({name:url})
		},
		inputCode(e) {
			this.code = e.detail.value;
		},
		sendCode:function(){
			let that = this
			if(!that.iGlobal.isMobile(that.mobile)){
				this.tui.toast('请输入正确的手机号');
				return false;
			}
			that.tui.request("/user/sendcode","POST",{
				mobile:that.mobile,
				type:'forgetpass'
			}).then((res)=>{
				console.log(res)
				if (res.code == 200) {
					console.log(res)
					this.tui.toast(res.message);
				} else {
					this.tui.toast(res.message);
				}
			}).catch((res)=>{})
		},
		inputMobile: function(e) {
			this.mobile = e.detail.value;
		},
		inputPwd: function(e) {
			this.password = e.detail.value;
		},
		clearInput(type) {
			if (type == 1) {
				this.mobile = '';
			} else {
				this.password = '';
			}
		}
	}
};
</script>

<style lang="scss">
.container {
	.tui-status-bar {
		width: 100%;
		height: var(--status-bar-height);
	}

	.tui-header {
		width: 100%;
		padding: 40rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		box-sizing: border-box;
	}

	.tui-page-title {
		width: 100%;
		font-size: 48rpx;
		font-weight: bold;
		color: $uni-text-color;
		line-height: 42rpx;
		padding: 40rpx;
		box-sizing: border-box;
	}
	
	.logo {
		width: 60%;
		height: 100px;
		border-radius: 10rpx;
		padding-top:20rpx;
	}
	
	.tui-my-input{
		border: 1px solid rgb(109, 122, 135);
		border-radius: 50px;
		padding: 10px 0px!important;
	}
	
	.tui-form {
		padding-top: 50rpx;

		.tui-view-input {
			width: 100%;
			box-sizing: border-box;
			padding: 0 40rpx;

			.tui-cell-input {
				width: 100%;
				display: flex;
				align-items: center;
				padding-top: 18.75rpx;
				padding-bottom: 18.75rpx;

				input {
					flex: 1;
					padding-left: $uni-spacing-row-base;
				}

				.tui-icon-close1 {
					margin-left: auto;
					padding-right: 12.5rpx;
				}
			}
		}
		.tui-btn-send {
					width: 156rpx;
					text-align: right;
					flex-shrink: 0;
					font-size: $uni-font-size-base;
					color: $uni-color-primary;
					padding-right: 5px;
				}
		.tui-cell-text {
			width: 100%;
			padding: $uni-spacing-col-lg $uni-spacing-row-lg;
			box-sizing: border-box;
			font-size: $uni-font-size-sm;
			color: $uni-text-color-grey;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.tui-color-primary {
				color: $uni-color-primary;
			}
		}

		.tui-btn-box {
			width: 100%;
			padding: 0 $uni-spacing-row-lg;
			box-sizing: border-box;
			margin-top: 80rpx;
		}
	}

	.tui-login-way {
		width: 100%;
		font-size: 26rpx;
		color: $uni-color-primary;
		display: flex;
		justify-content: center;
		position: fixed;
		left: 0;
		bottom: 80rpx;

		view {
			padding: 12rpx 0;
		}
	}

	.tui-auth-login {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		padding-bottom: 80rpx;
		padding-top: 20rpx;

		.tui-icon-platform {
			width: 90rpx;
			height: 90rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			position: relative;
			margin-left: 40rpx;

			&::after {
				content: '';
				position: absolute;
				width: 200%;
				height: 200%;
				transform-origin: 0 0;
				transform: scale(0.5, 0.5) translateZ(0);
				box-sizing: border-box;
				left: 0;
				top: 0;
				border-radius: 180rpx;
				border: 1rpx solid $uni-text-color-placeholder;
			}
		}

		.tui-login-logo {
			width: 60rpx;
			height: 60rpx;
		}
	}
}
</style>
